home *** CD-ROM | disk | FTP | other *** search
- (c) Copyright 1989-1999 Amiga, Inc. All rights reserved.
- The information contained herein is subject to change without notice, and
- is provided "as is" without warranty of any kind, either expressed or implied.
- The entire risk as to the use of this information is assumed by the user.
-
-
- Intro to IFF Amiga ILBM Files and Amiga Viewmodes
-
-
- The IFF, or Interchange File Format, for graphic images on the Amiga
- is called FORM ILBM (InterLeaved BitMap). It follows a standard
- parsable IFF format.
-
-
- Sample hex dump of beginning of an ILBM:
-
- Important note - you can NOT ever depend on any particular ILBM chunk
- being at any particular offset in the file! IFF files are composed,
- in their simplest form, of chunks within a FORM. Each chunk starts
- with a 4-letter chunk ID, followed by a 32-bit length for the rest of
- the chunk. When you parse an IFF file, skip past unneeded or unknown
- chunks by seeking their length (+1 if odd length) to the next 4-letter
- chunk ID.
-
- 0000: 464F524D 00016418 494C424D 424D4844 FORM..d.ILBMBMHD
- 0010: 00000014 01400190 00000000 06000100 .....@..........
- 0020: 00000A0B 01400190 43414D47 00000004 .....@..CAMG....
- 0030: 00000804 434D4150 00000030 001000E0 ....CMAP...0....
- 0040: E0E00000 20000050 30303050 50500030 .... ..P000PPP.0
- 0050: 90805040 70707010 60E02060 E06080D0 ..P@ppp.`. `.`..
- 0060: A0A0A0A0 90E0C0C0 C0D0A0E0 424F4459 ............BODY
- 0070: 000163AC F8000F80 148A5544 2ABDEFFF ..c.......UD*... etc.
-
-
-
- Interpretation:
-
- 'F O R M' length 'I L B M''B M H D'<-start of BitMapHeader chunk
- 0000: 464F524D 00016418 494C424D 424D4844 FORM..d.ILBMBMHD
-
- length WideHigh XorgYorg PlMkCoPd <- Planes Mask Compression Pad
- 0010: 00000014 01400190 00000000 06000100 .....@..........
-
- TranAspt PagwPagh 'C A M G' length <- start of C-AMiGa View modes chunk
- 0020: 00000A0B 01400190 43414D47 00000004 .....@..CAMG....
-
- Viewmode 'C M A P' length R g b R <- Viewmode 800=HAM | 4=LACE
- 0030: 00000804 434D4150 00000030 001000E0 ....CMAP...0....
-
- g b R g b R g b R g b R g b R g <- Rgb's are for reg0 thru regN
- 0040: E0E00000 20000050 30303050 50500030 .... ..P000PPP.0
-
- b R g b R g b R g b R g b R g b
- 0050: 90805040 70707010 60E02060 E06080D0 ..P@ppp.`. `.`..
-
- R g b R g b R g b R g b 'B O D Y'
- 0060: A0A0A0A0 90E0C0C0 C0D0A000 424F4459 ............BODY
-
- length start of body data <- Compacted (Compression=1 above)
- 0070: 000163AC F8000F80 148A5544 2ABDEFFF ..c.......UD*...
- 0080: FFBFF800 0F7FF7FC FF04F85A 77AD5DFE ...........Zw.]. etc.
-
-
- The CAMG Viewmode codes are HIRES=0x8000, LACE=0x4, HAM=0x800 and
- HALFBRITE=0x80.
-
-
-
- Interpreting ILBMs
-
-
- ILBM is a fairly simple IFF FORM. All you really need to deal with
- to extract the image are the following chunks:
-
- BMHD - Information about the size, depth and compaction method.
- (See interpreted hex dump above.)
-
- CAMG - Optional Amiga viewmodes chunk.
- Most HAM and HALFBRITE ILBMs should have this chunk. If no
- CAMG chunk is present, and image is 6 planes deep, assume
- HAM and you'll probably be right. Some Amiga viewmodes
- flags are HIRES=0x8000, LACE=0x4, HAM=0x800, HALFBRITE=0x80.
-
- CMAP - RGB values for color registers 0 to n.
- (Each component left justified in a byte.)
-
- BODY - The pixel data, stored in an interleaved fashion as follows
- (Note that each line is individually compacted if BMHD
- Compression = 1):
-
- plane 0 scan line 0
- plane 1 scan line 0
- plane 2 scan line 0
- ...
- plane n scan line 0
- plane 0 scan line 1
- plane 1 scan line 1
- etc.
-
- There are two ther chunks to watch out for - AUTH Author chunks and (c)
- Copyright chunks. Preserve any copyright information if you rewrite the
- ILBM.
-
-
-
- Body Compression
-
-
- The BODY contains pixel data for the image. Width, height, and depth
- (i.e. the number of bit-planes) are specified in the BMHD.
- If the BMHD Compression byte is 0, then the scan line data is not compressed.
- If Compression=1, then each scan line is individually compressed as follows:
-
- o More than 2 bytes the same stored as BYTE code value n from -1 to -127
- followed by byte to be repeated (-n) + 1 times.
-
- o Varied bytes stored as BYTE code n from 0 to 127 followed by n+1 bytes
- of data.
-
- o The byte code -128 is a NOP.
-
-
-
- Interpreting the Scan Line Data:
-
- If the ILBM is not HAM or HALFBRITE, then after parsing and uncompacting
- if necessary, you will have N planes of pixel data. The color register
- used for each pixel is specified by looking at each pixel through the
- planes. I.e. if you have 5 planes, and the bit for a particular pixel is
- set in planes 0 and 3:
-
- PLANE 4 3 2 1 0
- PIXEL 0 1 0 0 1
-
- then that pixel uses color register binary 01001 = decimal 9.
-
- The RGB value for each color register is stored in the CMAP chunk of the
- ILBM, starting with register 0. Each register's RGB value are stored as
- one byte of R, one byte G, and one byte of B, with each component left
- justified in the byte. I.e. Amiga R, G, and B components are each stored
- in the high nibble of a byte.
-
-
-
- But - if the picture is HAM or HALFBRITE, it is interpreted differently.
- Hopefully, if the picture is HAM or HALFBRITE, the package that created
- it also created a CAMG chunk. Look at an ASCII dump of your file. The
- chunks all start with a 4-character ASCII chunk ID. If the picture is 6
- planes deep and has no CAMG chunk, it is probably HAM. If you see a
- CAMG chunk in the file, the "CAMG" is followed by the 32-bit chunk length
- and then the 32-bit Amiga Viewmode flags. HAM pics will have the 0x800
- bit set in the CAMG chunk ViewModes. HALBRITE pics will have the 0x80
- bit set.
-
-
- How Amiga HAM Mode Works
-
- To transport a HAM or HALFBRITE picture to another machine, you must
- understand how HAM and HALFBRITE work on the Amiga.
-
- Amiga HAM (Hold and Modify) mode lets the Amiga display all 4096 RGB
- values. In HAM mode, the bits in the two last planes describe an R G or
- B modification to the color of the previous pixel on the line to create
- the color of the current pixel. So a 6-plane HAM picture has 4 planes
- for specifying absolute color pixels. This gives up to 16 absolute colors
- which would be specified in the ILBM CMAP chunk. The bits in the last
- two planes are color modification bits. These cause the Amiga, in HAM mode,
- to take the RGB value of the previous pixel, substitute the 4 bits in
- planes 0-3 for the previous color's R G or B component and then display the
- result at the current pixel. If the first pixel of a scan line is a
- modification pixel, it modifies the RGB value of the border color
- (register 0). The color modification bits in the last two planes
- (planes 4 and 5) are interpreted as follows:
-
- 00 - no modification. Use planes 0-3 as normal color register index
- 10 - hold previous, replacing Blue component with bits from planes 0-3
- 01 - hold previous, replacing Red component with bits from planes 0-3
- 11 - hold previous. replacing Green component with bits from planes 0-3
-
-
-
- How Amiga HALFBRITE mode works:
-
- This one is simpler. In HALFBRITE mode, the Amiga interprets the
- bit in the last plane as HALFBRITE modification - the bits in the other
- planes are treated as normal color register numbers. The RGB values for
- each color register are specified in the CMAP chunk. If the bit in the
- last plane is set to one, then that pixel is displayed at half brightness.
- This can provide up to 64 absolute colors.
-
-
- Other Notes
-
- Amiga ILBM images must be a even number of bytes wide. Smaller
- images, such as brushes, are padded to an even byte width.
-
- ILBMs created with Electronic Art's Deluxe Paint II on the Amiga are
- compatible with IBM version of DPaintII. You may have to use a '.lbm'
- filename extension on an IBM. The ILBM graphic files may be transferred
- between the two machines or between the Amiga and IBM sides of an A2000
- equipped with a CBM Bridgeboard.
-
-
-